<html>
<head>
<?php
include("../global_function.php");
include("../../type_model.php");
$file_name = $_SERVER["PHP_SELF"];
represent_html_header($file_name);
?>
</head>
<body>
<?php
	// 从数据库中得到所有的type列表
	$type_list = get_type_list();
	// 显示type列表
	represent_type_list($type_list);
?>
<body>
</html>
<?php
function represent_type_list($type_list)
{
	foreach ($type_list as $type)
	{
		represent_type($type);
	}
}

function represent_type($type)
{
	printf("<form action=\"edit_type.php?id=%d\" method=\"POST\">", $type["id"]);
	printf("分类名称：<input type=\"text\" name=\"name\" value=\"%s\"/>", $type["name"]);
	printf("<input type=\"submit\" name=\"submit\" value=\"更新\"/>");
	printf("<a href=\"delete_type.php?id=%d\">删除</a>", $type["id"]);
	printf("</form>");
}
?>
